﻿using System.Web;
using System.Web.Routing;

namespace Kratos.Framework.Routing.Constraint
{
    public class IsInt : IRouteConstraint
    {
        public IsInt() { }

        public IsInt(int minValue, int maxValue)
        {
            MinValue = minValue;
            MaxValue = maxValue;
        }

        public IsInt(int minValue, int maxValue, bool isOptional)
            : this(minValue, maxValue)
        {
            IsOptional = isOptional;
        }

        protected int MinValue { get; set; }

        protected int MaxValue { get; set; }

        /// <summary>
        /// 可选的参数,表示忽略检查
        /// </summary>
        protected bool IsOptional { get; set; }

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            var o = values[parameterName];
            return true;
        }
    }
}
